package util;

import model.UserInfo;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
 * @Author: wenjingyuan
 * @Date: 2023/03/30/7:36
 * @Description:获取登录的用户
 */
public class SessionUtils {
    public static UserInfo getLogInUser(HttpServletRequest req){
        UserInfo userInfo=null;
        HttpSession session= req.getSession(false);
        if(session!=null && (session.getAttribute(AppVar.SESSION_USERINFO_KEY)!=null)){
            userInfo=(UserInfo) session.getAttribute(AppVar.SESSION_USERINFO_KEY);
        }
        return  userInfo;
    }
}
